package com.lijin.batchsys.web.service.impl;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import com.lijin.batchsys.framework.common.BatchUtil;
import com.lijin.batchsys.framework.dao.BaseDAO;
import com.lijin.batchsys.framework.enums.BatchPageTable;
import com.lijin.batchsys.web.bean.PageInfo;
import com.lijin.batchsys.web.service.BaseService;

/**
 * 
 * @author HanBowen
 *
 */
public class BaseServiceImpl implements BaseService{

	@SuppressWarnings("unchecked") @Override
	public <T> void buildPageInfo(String fkId, PageInfo<T> pageInfo, BatchPageTable tableEnum, BaseDAO bsDAO) {
		//tableEnum 分页信息对应的数据库表名
		List<T> dataList = new ArrayList<T>();
		int firstResult = pageInfo.getFirstResult();  //页面开始数据
		int endResult = pageInfo.getEndResult();      //页面结尾数据
		int count = 0;                                //总数量
		Map<String, String> sqlMap;                   //SQL语句包括总数量和分页查询
		
		if(fkId != null){//通过FK外键进行相关查询
			
			/** 如果需要外键查询数据库，在此处进行setter **/
			if(tableEnum == BatchPageTable.BATCH_JOB_INFO || tableEnum == BatchPageTable.BATCH_STEP_INFO){
				pageInfo.setFkIntID(Integer.parseInt(fkId));
			}else if(tableEnum == BatchPageTable.BATCH_EXEC_LOG_DETAIL){
				pageInfo.setFkLongID(Long.parseLong(fkId));
			}
			
		   sqlMap = BatchUtil.buildSqlMapByID(tableEnum);
		}else{
			
	       sqlMap = BatchUtil.buildSqlMapNonID(tableEnum);
		}

		count = 0;
		dataList = null;
		
		pageInfo.setTotalrecord(count);
		pageInfo.setRecords(dataList);

	}




	
	
	
	
}
